#!/usr/bin/perl -w
#
use strict;

#//==========================================================================
#/*
# * Author   : cuisw <shaovie@gmail.com>
# * Date     : 2007-12-17
# * Describe : configurable service
# */
#//==========================================================================

my $include ="include/";
my $srcdir  = "src/";

foreach (@ARGV)
{
    my $className   = $_;
    my $author     = "cuisw";
    my $authorMail = "shaovie\@gmail.com";
    my $datestr    = qx/date "+%Y-%m-%d %H:%M"/;
    chop $datestr;
    open FILE , ">$include$className\.h";

    print FILE "//" . "=" x 72 . "\n";
    print FILE "/**" . "\n";
    print FILE " * Author   : $author <$authorMail>" . "\n";
    print FILE " * Date     : $datestr" . "\n";
    #print FILE " * Describe : " . "\n";
    print FILE " */\n";
    print FILE "//" . "=" x 72 . "\n\n";

    (my $preHeader = $className) =~ tr/a-z/A-Z/;
    print FILE "\#ifndef _$preHeader" . "_H_\n"; 
    print FILE "\#define _$preHeader" . "_H_\n";
    print FILE "\#include \"Pre.h\"\n\n";

    print FILE "/**\n * \@class $className\n *\n";
    print FILE " * \@brief \n */\n";

    my $className_ = "" . $className;
    print FILE "class $className_\n";
    print FILE "{\npublic:\n";
    print FILE " " x 4 . "$className_ ();\n\n";
    print FILE " " x 4 . "//\n";
    print FILE " " x 4 . "~$className_ ();\n";
    print FILE "private:\n";
    print FILE "};\n\n";
    print FILE "\#include \"Post.h\"\n";
    print FILE "\#endif\n\n";
    close FILE;
# cpp template
    open FILE , ">$srcdir$className\.cpp";
    print FILE "\#include \"$className\.h\"\n\n";
    print FILE "$className_" . "::" . "$className_ ()\n";
    print FILE "{\n\n}\n";
    print FILE "$className_" . "::" . "~$className_ ()\n";
    print FILE "{\n\n}\n\n";
    close FILE;
}
